Component({
    options: {
        addGlobalClass: true,
    },
    /**
     * 组件的属性列表
     */
    properties: {

    },
    /**
     * 组件的初始数据
     */
    data: {
        active: 0,
        tabbarList: [{
                pagePath: "/pages/index/index",
                text: "首页",
                iconPath: "cloud://cloudbase-0gqz5itzcf26913d.636c-cloudbase-0gqz5itzcf26913d-1354751998/images/home.png",
                selectedIconPath: "cloud://cloudbase-0gqz5itzcf26913d.636c-cloudbase-0gqz5itzcf26913d-1354751998/images/home-active.png"
            },
            {
                pagePath: "/pages/invite/index",
                text: "邀请",
                iconPath: "cloud://cloudbase-0gqz5itzcf26913d.636c-cloudbase-0gqz5itzcf26913d-1354751998/images/invite.png",
                selectedIconPath: "cloud://cloudbase-0gqz5itzcf26913d.636c-cloudbase-0gqz5itzcf26913d-1354751998/images/invite-active.png"
            },
            {
                pagePath: "/pages/data/index",
                text: "数据",
                iconPath: "cloud://cloudbase-0gqz5itzcf26913d.636c-cloudbase-0gqz5itzcf26913d-1354751998/images/data.png",
                selectedIconPath: "cloud://cloudbase-0gqz5itzcf26913d.636c-cloudbase-0gqz5itzcf26913d-1354751998/images/data-active.png"
            },
        ]
    },
    /**
     * 组件的方法列表
     */
    methods: {
        onTabbarChange(e) {
            this.setData({
                active: e.detail
            })
            wx.switchTab({
                url: this.data.tabbarList[e.detail].pagePath,
            })
        },
        init() {
            const page = getCurrentPages().pop();
            this.setData({
                active: this.data.tabbarList.findIndex(item => item.pagePath === `/${page.route}`)
            });
        }
    }
})